#include "pch.h"
#include "KRepresentLoopThreadCallList.h"
typedef_getHandlerObj getHandlerObj = 0;
typedef_AutoMoveToPoint AutoMoveToPoint = 0;
typedef_GameWorldPositionToScenePosition GameWorldPositionToScenePosition = 0;
void CAutoMoveToPoint::UseCall()
{
	if (!getHandlerObj)
	{
		getHandlerObj = (typedef_getHandlerObj)(getjx3representx64() + getHandlerObj_CALL);
	}
	if (!AutoMoveToPoint)
	{
		AutoMoveToPoint = (typedef_AutoMoveToPoint)(getjx3representx64() + AutoMoveToPoint_CALL);
	}
	GameWorldPositionToScenePosition = (typedef_GameWorldPositionToScenePosition)((DWORD64)GetModuleHandleA("kg3dengineadapterx64.dll") + 0x5C610);

	float output[4] = {0};
	GameWorldPositionToScenePosition(0x00001C20AF6BB08, output, m_x, m_y, m_z, 0);
	PrintA("fs: %.0f , %.0f , %.0f" , output[0] , output[1] , output[2]);

	DWORD64 getHandlerObj_rcx = read<DWORD64>(getjx3representx64() + AutoMoveToPoint_call_rcx_base);
	if (!IsBadReadPtr((const void*)(getHandlerObj_rcx), 8))
	{
		DWORD64 HandlerObj = getHandlerObj(getHandlerObj_rcx + AutoMoveToPoint_call_rcx_offset, 1);
		if (!IsBadReadPtr((const void*)(HandlerObj), 8))
		{
			DWORD64 AutoMoveToPoint_rcx = read <DWORD64>(HandlerObj);
			if (!IsBadReadPtr((const void*)(AutoMoveToPoint_rcx), 8))
			{
				float point[4] = { output[0] , output[1] , output[2] , 0};
				AutoMoveToPoint(AutoMoveToPoint_rcx, point);
			}
		}

	}

	SetEvent();
}
